package com.zheng.study.base.bean.search.result;

import com.zheng.study.base.bean.search.Search;
import org.springframework.util.Assert;

/**
 * newFile
 * ============================================================================
 * author : dzw
 * createDate:  2018/6/12 。
 * ============================================================================
 */
public class SearchResultCount extends SearchResult {

	private final Long count;

	public SearchResultCount(Search search, Long count) {
		super(search);
		this.count = count;
	}

	public Long getCount() {
		return count;
	}

	public static SearchResultCount countResult (Search search, Long count){
		return newBuilder().setSearch(search).setCount(count).build();
	}

	public static Builder newBuilder(){
		return new Builder();
	}

	public static class Builder extends SearchResult.Builder<SearchResult, Builder>{

		private Long count;

		public Builder setCount(Long count) {
			this.count = count;
			return this;
		}

		@Override
		protected Builder getThis() {
			return this;
		}

		@Override
		public SearchResultCount build() {
			Assert.notNull(search, "search 不能为空");
			return new SearchResultCount(search, count);
		}
	}

}
